import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../layout/Home.vue'
import Goods from '../views/Goods/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    redirect: '/goods',
    children: [
      {
        path: '/goods',
        component: Goods
      },
      {
        path: '/commons',
        component: () =>
          import(/* webpackChunkName: "commons" */ '../views/Commons/index.vue')
      },
      {
        path: '/shop',
        component: () =>
          import(/* webpackChunkName: "shop" */ '../views/Shop/index.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
